Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraction to OCaml + OCaml wrapper code #18

Merged
merged 2 commits into from
Oct 21, 2022

Conversation

Armael
Copy link
Contributor

@Armael Armael commented Oct 10, 2022

(This PR is based on top of #17.)

I marked this PR as WIP as it could need some work (and the history needs squashing/rebasing), cf also #16 .
The current status is that the PR adds OCaml code that should be on-par with the Haskell code functionality wise; the mkfs and fuse binaries seem to work, but performance is currently not good.

I thought it would nevertheless be a useful datapoint. I'm interested to know whether you think this would be worth merging into the repo (now or after some more work), or whether I should rather work on it on the side.

@zeldovich
Copy link
Member

Thanks for doing all this work. This looks pretty reasonable, and should be a nice improvement for the Ocaml code for anyone that wants to use that. I'd be happy to merge this into the repo, in some form. Let me know if you think this is more-or-less the final state for these changes, or if you want to clean it up further before merging.

This is mostly functional, but performance is an issue
- mkfs and the fuse wrapper work
- we vendor ocamlfuse, with patches to add support for an extra
  `mknod` argument and the `destroy` callback. These should be
  upstreamed at some point.
- TODO: add support for the `create` callback in fuse
- TODO: support for timings (the Rdtsc operation)

(but the main TODO to make this usable is improving performance)
@Armael Armael changed the title Extraction to OCaml + OCaml wrapper code (WIP) Extraction to OCaml + OCaml wrapper code Oct 16, 2022
@Armael
Copy link
Contributor Author

Armael commented Oct 16, 2022

Thanks! I've just squashed the intermediate commits; this should be in a mergeable state now.


Set Implicit Arguments.

(* Disk value and address types *)

Notation "'valubytes_real'" := (4 * 1024)%nat. (* 4KB *)
Notation "'valubytes_real'" := (HexString.to_nat "0x1000"). (* 4KB *)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious: what's the rationale for using HexString.to_nat instead of doing the computation directly in nat as before? Does this help avoid some kind of degenerate nat performance issue with Ocaml extraction? I have to admit I've never even known about HexString.to_nat before seeing this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, otherwise (AFAIR) the generated OCaml code would be building a nat by piling up 1024 S constructors, and that would make compiling (!) the ocaml code quite slow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense; thanks!

@zeldovich zeldovich merged commit 2c7ef9c into mit-pdos:master Oct 21, 2022
@Armael
Copy link
Contributor Author

Armael commented Oct 21, 2022

Thanks for the review and the merge!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants